import 'package:flutter/material.dart';

//账号管理
class AccountManagementPage extends StatelessWidget {
  const AccountManagementPage({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: const Text('账号管理'),
        centerTitle: true,
        backgroundColor: Colors.white,
        foregroundColor: Colors.black,
        elevation: 0.5,
      ),
      backgroundColor: const Color(0xFFF2F2F2),
      body: ListView(
        children: [
          const SizedBox(height: 10),

          // 手机号
          buildItemGroup([
            buildItem('手机号', '已绑定: 138****8888'),
            buildItem('微信号', 'wxid_123456789', showArrow: false),
          ]),

          const SizedBox(height: 10),

          buildItemGroup([
            buildItem('QQ号', '未绑定'),
            buildItem('邮箱地址', '未绑定'),
          ]),

          const SizedBox(height: 30),

          // 提示说明
          const Padding(
            padding: EdgeInsets.symmetric(horizontal: 16),
            child: Text(
              '你可以绑定常用的 QQ 号或邮箱，方便在不同设备登录。',
              style: TextStyle(fontSize: 14, color: Colors.grey),
            ),
          ),
        ],
      ),
    );
  }

  // 分组容器
  Widget buildItemGroup(List<Widget> children) {
    return Container(
      color: Colors.white,
      child: Column(
        children: children,
      ),
    );
  }

  // 普通条目
  Widget buildItem(String title, String value, {bool showArrow = true}) {
    return Column(
      children: [
        ListTile(
          title: Text(title, style: const TextStyle(fontSize: 16)),
          trailing: Row(
            mainAxisSize: MainAxisSize.min,
            children: [
              Text(value, style: const TextStyle(color: Colors.grey)),
              if (showArrow) const SizedBox(width: 8),
              if (showArrow) const Icon(Icons.arrow_forward_ios, size: 16),
            ],
          ),
          onTap: () {
            // TODO: 点击事件，如跳转绑定页面
          },
        ),
        const Divider(height: 0.5),
      ],
    );
  }
}
